/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import javax.swing.*;
import java.io.Console;
import java.util.Scanner;

/**
 * <p>Project: app2022 - InputDemo
 * <p>Powered by webrx On 2022-01-06 17:14:10
 *
* @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class InputDemo {

    public static void main(String[] args) {
        String name = JOptionPane.showInputDialog("请输入姓名：");
        //System.out.println("欢迎：" + name);
        JOptionPane.showMessageDialog(null, "欢迎：" + name);
    }

    public static void main33(String[] args) {
        Console c = System.console();
        if (c == null) {
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入账号：");
            String name = sc.nextLine();
            System.out.println("请输入密码：");
            String pwd = sc.nextLine();
            if ("admin".equalsIgnoreCase(name) && "123".equals(pwd)) {
                System.out.printf("欢迎：%s，进入系统。%n", name);
            } else {
                System.out.printf("登录失败，系统退出。%n");
            }
        } else {
            String name = c.readLine("请输入账号：");
            String pwd = new String(c.readPassword("请输入密码："));
            if ("admin".equalsIgnoreCase(name) && "123".equals(pwd)) {
                System.out.printf("欢迎：%s，进入系统。%n", name);
            } else {
                System.out.printf("登录失败，系统退出。%n");
            }
        }
    }

    public static void main22(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.print("请输入a b:");
            if (sc.hasNextInt()) {
                int a = sc.nextInt();
                int b = sc.nextInt();
                System.out.printf("%d + %d = %d%n", a, b, a + b);
            } else {


                //break;
            }
        }
    }

    public static void main11(String[] args) {
        int a = 1;
        int b = 2;
        if (args.length == 2) {
            a = Integer.parseInt(args[0]);
            b = Integer.parseInt(args[1]);
        }
        System.out.printf("%d + %d = %d%n", a, b, a + b);
    }
}
